package com.gzucm.Scholarship.common.enums;

import com.gzucm.Scholarship.exception.UserTypeException;

public enum UserType {
    ADMIN,
    STUDENT,
    TEACHER,
    CLASS_CADRES;

    public Integer getCode() {
        switch (this) {
            case ADMIN:
                return -1;
            case STUDENT:
                return 0;
            case TEACHER:
                return 1;
            case CLASS_CADRES:
                return 2;
        }
        throw new UserTypeException(-9999, "不存在的UserType");
    }

    public static UserType get(int code) {
        switch (code) {
            case -1:
                return ADMIN;
            case 0:
                return STUDENT;
            case 1:
                return TEACHER;
            case 2:
                return CLASS_CADRES;
        }
        throw new UserTypeException(code, "不存在Code为：" + code + " 的UserType");
    }
}
